#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    int minNumberOfFrogs(string croakOfFrogs) {
        map<char, int>h;
        map<char, char>g({ {'c','k'},{'k','a'},{'a','o'},{'o','r'},{'r','c'} });
        for (int i = 0; i < croakOfFrogs.size(); i++)
        {
            char cur = croakOfFrogs[i];
            if (h[g[cur]])h[g[cur]]--;
            else if (cur != 'c') return -1;
            h[cur]++;
        }
        if (h['c'] || h['r'] || h['o'] || h['a'])return -1;
        return h['k'];
    }
};